<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #chart {
            width: 500px;
            height: 400px;
            outline: 1px solid red;
        }
    </style>
</head>
<body>
    <div id="chart"></div>

    <script src="../lib/echart.min.js"></script>
    <script>

        const data = [
            {
                day: 'Mon',
                value1: 150,
                value2: 152,
                value3: 154,
            },
            {
                day: 'Tue',
                value1: 155,
                value2: 158,
                value3: 159,
            },
            {
                day: 'Wed',
                value1: 170,
                value2: 167,
                value3: 158,
            },
            {
                day: 'Thu',
                value1: 150,
                value2: 152,
                value3: 154,
            },
            {
                day: 'Fri',
                value1: 140,
                value2: 130,
                value3: 145,
            },
            {
                day: 'Sat',
                value1: 150,
                value2: 155,
                value3: 159,
            },
            {
                day: 'Sun',
                value1: 170,
                value2: 180,
                value3: 190,
            },
        ];

        // 1. 初始化echarts容器
        const chartContainer = document.querySelector('#chart');
        const chart = echarts.init(chartContainer);

        // 2. 写配置项
        const options = {
            color: [
                {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'red' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'rgba(255, 0, 0, .5)' // 100% 处的颜色
                    }],
                },
                {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'green' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'rgba(0, 255, 0, .5)' // 100% 处的颜色
                    }],
                },
                {
                    type: 'linear',
                    x: 0,
                    y: 0,
                    x2: 0,
                    y2: 1,
                    colorStops: [{
                        offset: 0, color: 'blue' // 0% 处的颜色
                    }, {
                        offset: 1, color: 'rgba(0, 0, 255, .5)' // 100% 处的颜色
                    }],
                },
            ],
            tooltip: {},
            legend: {
                data: ['1', '2', '3'],
                textStyle: {
                    color: 'red',
                }
            },
            xAxis: {
                type: 'category',
                data: data.map(item => item.day),
                axisLine: {
                    show: false,
                },
                axisTick: {
                    show: false,
                },
                axisLabel: {
                    // color: 'red',
                },
                name: 'x',
                // data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
            },
            yAxis: {
                type: 'value',
                splitNumber: 2,
                name: 'y',
                splitLine: {
                    show: false,
                }
                // show: false,
            },
            series: [
                {
                    name: '1',
                    data: data.map(item => item.value1),
                    type: 'line',
                    smooth: true,
                    showSymbol: false,
                },
                {
                    name: '2',
                    data: data.map(item => item.value2),
                    type: 'bar',
                },
                {
                    name: '3',
                    data: data.map(item => item.value3),
                    type: 'bar',
                },
            ],
        };

        // 3. 导入配置项
        chart.setOption(options);

    </script>
</body>
</html>